#include <stdint.h>

#include "vicl.h"

VixPropertyID get_vm_vcpu_count(int idx)
{
    VixPropertyID vcpus = 0;

    // Test the power state.
    err = Vix_GetProperties(vmachine[idx].handle,
                            VIX_PROPERTY_VM_NUM_VCPUS,
                            &vcpus,
                            VIX_PROPERTY_NONE);

    if(VIX_OK != err) 
    {
        VICL_ERROR("get_vm_vcpu_count(%u) failed {%x}", idx, err);
        for(;;);
        return -1;
    }    
    
    return vcpus;
}

VixPropertyID get_vm_memory_size(int idx)
{
    VixPropertyID mem = 0;

    // Test the power state.
    err = Vix_GetProperties(vmachine[idx].handle,
                            VIX_PROPERTY_VM_MEMORY_SIZE,
                            &mem,
                            VIX_PROPERTY_NONE);

    if(VIX_OK != err) 
    {
        VICL_ERROR("get_vm_vcpu_count(%u) failed {%x}", idx, err);
        for(;;);
        return -1;
    }    
    
    return mem;
}

static char* read_vm_variable_ret = NULL;
char* read_vm_variable(int idx, const char* name)
{

    jobHandle = VixVM_ReadVariable(vmachine[idx].handle,    // handle
                                   VIX_VM_CONFIG_RUNTIME_ONLY,   // variable type
                                   name,                    // name
                                   0,                       // options
                                   NULL,                    // callbackProc
                                   NULL);                   // clientData
    err = VixJob_Wait(jobHandle, 
                      VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING,
                      &read_vm_variable_ret,
                      VIX_PROPERTY_NONE);
    if(VIX_OK != err)
    {
        VICL_ERROR("read_vm_variable(%u, %s) failed {%x}", idx, name, err);
        return NULL;
    }

    return read_vm_variable_ret;
}







